
//整理收件人列表
function SNToName(){
	var ToName=GetID("toname").value.split(",");
	var NewToName="";
	var id=0;
	for(var i=0;i<ToName.length;i++){
		if(ToName[i]!=""){
			if(id==0){
				NewToName=ToName[i];
			}else{
				NewToName=NewToName+","+ToName[i];
			}
			id++;
		}
	}
	GetID("toname").value=NewToName;
}

//好友列表选择
function addToName(){
	var obj = document.getElementsByName("Fir")[0];
	for(var i=0; i<obj.options.length; i++) {
		if(obj.options[i].selected){
			if(GetID("toname").value=="在此加入接收人名称^_^"){
				GetID("toname").value=obj.options[i].text;
			}else{
				SNToName();
				var OldData=GetID("toname").value.split(",");
				if(OldData.length<10){
					var ok=1;
					for(var j=0;j<OldData.length;j++){
						if(obj.options[i].text==OldData[j]){
							ok=0;
							break;
						}
					}
					if(ok){
						if(GetID("toname").value!=""){
							GetID("toname").value=GetID("toname").value+","+obj.options[i].text;
						}else{
							GetID("toname").value=obj.options[i].text;
						}
					}else{
						alert(obj.options[i].text+" 已经存在收件人中。");
					}
				}else{
					alert("已经达到最大发送人数。");
				}
			}
		}
	}
}

function _PHPText_SetCookie(name, value){
  var Then=new Date();
  Then.setTime(Then.getTime()+1000*31536000);
  var cookie_str = name + "=" + escape(value)+";expires="+Then.toGMTString();
  document.cookie = cookie_str;
}

function _PHPText_GetCookie(name){
  if (!name) return '';
  var raw_cookies, tmp, i;
  var cookies = new Array();
  raw_cookies = document.cookie.split('; ');
  for (i=0; i < raw_cookies.length; i++){
    tmp = raw_cookies[i].split('=');
    cookies[tmp[0]] = unescape(tmp[1]);
  }
  if (cookies[name] != null){
    return cookies[name];
  } else {
    return '';
  }
}

var StyleCName=new Array("天蓝","银灰","橘色","深红","墨绿","经典");
var StyleEName=new Array("Blue","Gray","Orange","Red","Green","Blue2");
//设置风格
function _PHPText_Style_SetStyle(title) {
  var i, links;
  links = document.getElementsByTagName("link");
  for(i=0; links[i]; i++) {
    if(links[i].getAttribute("rel").indexOf("style") != -1 && links[i].getAttribute("title")) {
      links[i].disabled = true;
      if(links[i].getAttribute("title").indexOf(title) != -1){
        links[i].disabled = false;
      }
    }
  }
}
//设置风格当前提示
function _PHPText_SetStyle(id){
	var i;	
	id++;
	for(i=1;i<6;i++){
		if(i==id){
			GetID("Style_"+i).className="fontdseletd";
		}else{
			GetID("Style_"+i).className="fontd";
		}
	}
}
//保存风格
function _PHPText_ChangeStyle(title){	
	_PHPText_SetCookie("StyleValue",title);
	
	_PHPText_Style_SetStyle(StyleCName[title]);
	_PHPText_SetStyle(title);
}
//获取当前风格
function _PHPText_ReadStyle(){	
	var title = _PHPText_GetCookie("StyleValue");
	
	if(title!=''){
		_PHPText_Style_SetStyle(StyleCName[title]);
		_PHPText_SetStyle(title);
	}else{
		_PHPText_ChangeStyle(0);
	}

}
